#ifndef _COLLISION_DETECTOR_H_
#define _COLLISION_DETECTOR_H_

#include "world.h"
#include "world_entity.h"

#define null '\0'

/* tipi di collisioni */
enum {ORTHO_COLLISION};

/* parametri collisione ortho */
enum {LEFT = 1, RIGHT, UP, DOWN, NONE};

extern GLfloat col1[3];

//class WorldEntity;
class World;
class PhysicsCalc;
class WorldArea;
class WorldEntity;
class WorldPlayer;
class WorldProjectile;

/* classi usate per restituire al PhysicsCalc informazioni sulle collisioni avvenute */
class CollisionInfo
{
	protected:
		char m_type;
		bool willCollide;
		
	public:
		CollisionInfo(void);
		CollisionInfo(bool wC);
		CollisionInfo(const CollisionInfo &copy);
		~CollisionInfo(void);
		
	friend class PhysicsCalc;
};

class PlayerOrthoCollision : public CollisionInfo
{
	private:
		/* lato sul quale collidono, relativo all'area */
		char m_side;
		/* profondita' della collisione, per aggiustamenti successivi del risolutore di collisioni */
		float m_depth;
		
	public:
		PlayerOrthoCollision(bool wC, char side, float depth);
		PlayerOrthoCollision(const PlayerOrthoCollision &copy);
		~PlayerOrthoCollision(void);
		
	friend class PhysicsCalc;
};

class ProjectileOrthoCollision : public CollisionInfo
{
	private:

		
	public:
		char m_side;
		float m_x, m_y;
		ProjectileOrthoCollision(bool wC, float x, float y, char side);
		ProjectileOrthoCollision(const ProjectileOrthoCollision &copy);
		~ProjectileOrthoCollision(void);
};
		
class CollisionDetector
{
	private:
		void orthoMinMax(GLfloat vertexs[8], float &top, float &bottom, float &left, float &right);

	public:
		CollisionDetector(void);
		~CollisionDetector(void);

		CollisionInfo *resolveCollision(WorldEntity *entity1, WorldEntity *entity2);
		CollisionInfo *resolveCollision(WorldPlayer *entity1, WorldArea *entity2);
		CollisionInfo *resolveCollision(WorldProjectile *entity1, WorldArea *entity2);
};



#endif
